package mmc.networking;

import mmc.RemoteServer;
import mmc.action.buff.Buff;
import mmc.action.skill.Skill;
import mmc.server.RemoteClient;
import mmc.ui.Text;

public class EndCast extends Message {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private boolean success = false;
	
	public EndCast()
	{
		
	}
	
	public EndCast(boolean success){
		this.success = success;
	}
	
	@Override
	public void executeOnClient(RemoteServer context){
		if(Skill.actualCast != null){
			
			if(success){
				if(Skill.actualCast instanceof Buff){
					Buff.buffs.put((Buff) Skill.actualCast, ((Buff)Skill.actualCast).duration);
				}
				else{
					Skill.actualCast.activateCooldown();
				}				
			}
			else
				Text.addMessage("Cast interrupted");
			
			Skill.interruptCast();
		}
	}
	
	@Override
	public void executeOnServer(RemoteClient context)
	{
		context.getPlayer().interruptCast();
	}
}
